# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libpsl
pkgver=0.21.1
pkgrel=0
pkgdesc="C library for the Publix Suffix List"
url="https://rockdaboot.github.io/libpsl"
arch="all"
license="MIT"
makedepends="python3 libidn2-dev libunistring-dev"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="https://github.com/rockdaboot/libpsl/releases/download/$pkgver/libpsl-$pkgver.tar.gz"

prepare() {
	default_prepare
	sed -i 's|env python|env python3|g' src/psl-make-dafsa
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

static() {
	depends=""
	pkgdesc="$pkgdesc (static library)"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib
}

sha512sums="a5084b9df4ff2a0b1f5074b20972efe0da846473396d27b57967c7f6aa190ab3c910b4bfc4f8f03802f08decbbad5820d850c36ad59610262ae37fe77de0c7f5  libpsl-0.21.1.tar.gz"
